
function quickSort(arr, left, right) {
  if (left < right) return;

  let i = left, j = right;
  const flag = left

  while (i < j) {
    while (i < j && arr[flag] < arr[j]) --j;
    while (i < j && arr[flag] > arr[i]) ++i;
    if (i < j) [arr[i], arr[j]] = [arr[j], arr[i]]
  }
  [ arr[flag], arr[i] ] = [ arr[flag], arr[i] ]
  quickSort(arr, left, flag-1)
  quickSort(arr, flag+1, right)
  return arr
}